package com.coffeeloversupportlibrary.coffeelover.domain.coffeebean;

import com.coffeeloversupportlibrary.R;
import com.coffeeloversupportlibrary.coffeelover.domain.article.ArticleModel;
import com.coffeeloversupportlibrary.coffeelover.domain.coffeebean.adapter.BeanMainAdapter;
import com.coffeeloversupportlibrary.coffeelover.domain.coffeebean.entity.CoffeeBean;
import com.coffeeloversupportlibrary.coffeelover.domain.coffeebean.type.ContentType;
import com.coffeeloversupportlibrary.core.base.BaseViewModel;
import com.coffeeloversupportlibrary.core.base.livadata.SingleLiveEvent;
import com.coffeeloversupportlibrary.core.data.DataRepository;

import java.util.ArrayList;
import java.util.List;

/**
 * @author puyv
 * @createTime 2021/11/12 13:17
 * @projectName CoffeeLoverSupportLibrary
 * @className BeansViewModel.java
 * @description TODO
 */
public class BeansViewModel extends BaseViewModel {
    private SingleLiveEvent<BeanMainAdapter> loadData=new SingleLiveEvent<>();

    public SingleLiveEvent<BeanMainAdapter> getLoadData(){
        return this.loadData;
    }

    public void init(){
        // 网络请求或数据库服务切到子线程进行
        loadData.setValue(create());
    }
    @Override
    protected void setModel() {
        mModel=new ArticleModel(DataRepository.getInstance());
    }
    private BeanMainAdapter create(){
        List<ContentType> lists=new ArrayList<ContentType>();


        CoffeeBean coffeeBean1=new CoffeeBean(R.drawable.coffee);
        CoffeeBean coffeeBean2=new CoffeeBean(R.drawable.coffee);
        CoffeeBean coffeeBean3=new CoffeeBean(R.drawable.coffee);
        CoffeeBean coffeeBean4=new CoffeeBean(R.drawable.coffee);
        CoffeeBean coffeeBean5=new CoffeeBean(R.drawable.coffee);
        CoffeeBean coffeeBean6=new CoffeeBean(R.drawable.coffee);
        CoffeeBean coffeeBean7=new CoffeeBean(R.drawable.coffee);
        CoffeeBean coffeeBean8=new CoffeeBean(R.drawable.coffee);
        CoffeeBean coffeeBean9=new CoffeeBean(R.drawable.coffee);
        CoffeeBean coffeeBean10=new CoffeeBean(R.drawable.coffee);


        List<CoffeeBean> datas=new ArrayList<CoffeeBean>();
        datas.add(coffeeBean1);
        datas.add(coffeeBean2);
        datas.add(coffeeBean3);
        datas.add(coffeeBean4);
        datas.add(coffeeBean5);
        datas.add(coffeeBean6);
        datas.add(coffeeBean7);
        datas.add(coffeeBean8);
        datas.add(coffeeBean9);
        datas.add(coffeeBean10);

        List<String> titles = new ArrayList<>();
        titles.add("推荐");
        titles.add("国内");
        titles.add("国际");
        titles.add("娱乐");

        ContentType contentType=new ContentType(titles,datas);
        lists.add(contentType);
        return new BeanMainAdapter(lists);
    }
}
